home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / os2 / gnuwget.zip / wget-1.4.3 / src / http.h < prev    next >
C/C++ Source or Header  |  1997-01-30  |  4KB  |  109 lines

  1. /* Declarations for HTTP support.
  2.    Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
  3.    
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2 of the License, or
  7.    (at your option) any later version.
  8.    
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.    
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  17.  
  18.  
  19. #ifndef HTTP_H
  20. #define HTTP_H
  21.  
  22. /* Header HTTP definitions */
  23. #define CONTLEN_H "Content-length:"
  24. #define CONTRANGE_H "Content-Range:"
  25. #define ACCEPTRANGES_H "Accept-Ranges:"
  26. #define CONTTYPE_H "Content-type:"
  27. #define LOCATION_H "Location:"
  28. #define LASTMODIFIED_H "Last-Modified:"
  29. #define TEXTHTML_S "text/html"
  30. #define HTTP_ACCEPT "*/*"
  31.  
  32. /* Some status code validation macros: */
  33. #define H_20X(x)        (((x) >= 200) && ((x) < 300))
  34. #define H_PARTIAL(x)    ((x) == HTTP_PARTIAL_CONTENTS)
  35. #define H_REDIRECTED(x) (((x) == HTTP_MOVED_PERMANENTLY) || ((x) == HTTP_MOVED_TEMPORARILY))
  36.  
  37. /* HTTP/1.0 status codes from RFC1945, given for reference. */
  38. /* Successful 2xx. */
  39. #define HTTP_OK                200
  40. #define HTTP_CREATED           201
  41. #define HTTP_ACCEPTED          202
  42. #define HTTP_NO_CONTENT        204
  43. #define HTTP_PARTIAL_CONTENTS  206
  44.  
  45. /* Redirection 3xx. */
  46. #define HTTP_MULTIPLE_CHOICES  300
  47. #define HTTP_MOVED_PERMANENTLY 301
  48. #define HTTP_MOVED_TEMPORARILY 302
  49. #define HTTP_NOT_MODIFIED      304
  50.  
  51. /* Client error 4xx. */
  52. #define HTTP_BAD_REQUEST       400
  53. #define HTTP_UNAUTHORIZED      401
  54. #define HTTP_FORBIDDEN         403
  55. #define HTTP_NOT_FOUND         404
  56.  
  57. /* Server errors 5xx. */
  58. #define HTTP_INTERNAL          500
  59. #define HTTP_NOT_IMPLEMENTED   501
  60. #define HTTP_BAD_GATEWAY       502
  61. #define HTTP_UNAVAILABLE       503
  62.  
  63. /* Typedefs: */
  64. typedef struct {
  65.    long len;                    /* Received length. */
  66.    long contlen;                /* Expected length. */
  67.    long restval;                /* The restart value. */
  68.    int res;                     /* The result of last read. */
  69.    char *newloc;                /* New location (redirection). */
  70.    char *remote_time;           /* Remote time-stamp string. */
  71.    char *error;                 /* Textual HTTP error. */
  72.    int statcode;        /* Status code. */
  73.    long dltime;                 /* Time of the download. */
  74. } http_stat_t;
  75.  
  76. /* A macro to free the elements of hstat. */
  77. #define FREEHSTAT(x)                            \
  78. do                                              \
  79. {                                               \
  80.    if (x.newloc)                                \
  81.       free(x.newloc);                           \
  82.    if (x.remote_time)                           \
  83.       free(x.remote_time);                      \
  84.    if (x.error)                                 \
  85.       free(x.error);                            \
  86.    x.newloc = x.remote_time = x.error = NULL;   \
  87. } while (0)
  88.  
  89. /* Function declarations */
  90. uerr_t fetch_next_header PARAMS((int, char **));
  91.  
  92. int hskip_lws PARAMS((const char *));
  93. int hparsestatline PARAMS((const char *, const char **));
  94. long hgetlen PARAMS((const char *));
  95. long hgetrange PARAMS((const char *));
  96. char *hgettype PARAMS((const char *));
  97. char *hgetlocation PARAMS((const char *));
  98. char *hgetmodified PARAMS((const char *));
  99. int haccepts_none PARAMS((const char *));
  100.  
  101. uerr_t gethttp PARAMS((urlinfo *, http_stat_t *, int *));
  102. uerr_t http_loop PARAMS((urlinfo *, char **, int *));
  103.  
  104. char *base64_encode_line PARAMS((const char *));
  105. time_t mktime_from_utc PARAMS((struct tm *));
  106. time_t http_atotm PARAMS((char *));
  107.  
  108. #endif /* HTTP_H */
  109.